Conversation
|
Sorry for being late. This now conflicts. |
|
@mcollina rebased, PTAL |
There was a problem hiding this comment.
Pull Request Overview
This pull request adds a convertConstToEnum configuration option to control whether JSON Schema const keywords are automatically converted to enum in OpenAPI specifications. The const keyword was added in OpenAPI 3.1 but is not supported by all tools (like swagger-ui), so this option allows users to preserve const when using OpenAPI 3.1.0+ or convert it to enum for compatibility.
Key changes:
- Added
convertConstToEnumoption with a default value oftruefor backward compatibility - Modified schema conversion logic to conditionally convert
consttoenumbased on the option - Added comprehensive tests for both behaviors (preserving
constand converting toenum)
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/mode/dynamic.js | Sets default value of convertConstToEnum to true |
| lib/spec/openapi/utils.js | Adds convertConstToEnum to options flow and implements conditional conversion logic |
| lib/spec/openapi/index.js | Passes options through to utility functions |
| index.d.ts | Adds TypeScript type definition and documentation for the new option |
| test/spec/openapi/schema.test.js | Adds tests for both preserving const and converting to enum |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Eomm
left a comment
There was a problem hiding this comment.
We should update the readme as well
4f6e005 to
825743c
Compare
|
@Eomm Updated the README |
Provides a new
convertConstToEnumoption in order to fix #876.I had to pipe the plugin options throughout all the functions in
openapi/util.js, let me know if there was a better way to do that.Checklist
npm run testandnpm run benchmarknpm run benchmarkdoes not seem to exist?npm run testsucceeds.and the Code of conduct